<?php

namespace Common\Model;

use Think\Model;

class UserSessionModel extends Model
{
    /**
     * Session 垃圾回收
     * @access public
     * @param string $sessMaxLifeTime
     */
    public function gc()
    {
        $map = array(
            'expire' => array('elt', time()),
        );
        return $this->db->where($map)->delete();
    }

    /**
     * 强制某用户下线
     * @param $uid
     */
    public function outline($uid, $type) {
        $map = array(
            'uid'=>$uid,
        );
        if(is_string($type)) {
            $map['type'] = $type;
        }else if(is_array($type)) {
            $map = array_merge($map, $type);
        }
        return $this->where($map)->delete();
    }
}